package aupdg.logic.mining.wrapper;

import aupdg.data.Log;
import aupdg.data.wrapper.ProMLog;
import aupdg.logic.mining.AlphaAlgorithm;
import aupdg.data.model.Petrinet;
import aupdg.data.model.wrapper.ProMPetrinet;
import org.processmining.framework.log.LogReader;
import org.processmining.mining.MiningResult;
import org.processmining.mining.petrinetmining.AlphaPPProcessMiner;
import org.processmining.mining.petrinetmining.PetriNetResult;

/**
 * It is a wrapper of AlphaAlgorithm, the class used in ProM to load and read
 * the event log file in MXML format.
 *
 * @author AA and CJ
 */
public class ProMAlphaPP implements AlphaAlgorithm {

    private AlphaPPProcessMiner miner = new AlphaPPProcessMiner();

    @Override
    public Petrinet mine(Log log) {
        LogReader lr = null;
        if (log instanceof ProMLog) {
            lr = (LogReader) log.getInnerLog();
        }


        MiningResult result = miner.mineAuLDG(lr);
        PetriNetResult pnResult = (PetriNetResult) result;
        ProMPetrinet petrinet = new ProMPetrinet(pnResult.getPetriNet());


        return petrinet;
    }

    @Override
    public Object getInnerAlgorithm() {
        return miner;
    }
}
